package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.GoodsSkuInfo;
import com.ruoyi.service.IGoodsSkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位信息操作处理
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/webshop/goodsSkuInfo")
public class GoodsSkuInfoController extends BaseController {
    @Autowired
    private IGoodsSkuInfoService goodsSkuInfoService;

    @GetMapping("/list")
    public TableDataInfo list(GoodsSkuInfo goodsSkuInfo)
    {
        startPage();
        List<GoodsSkuInfo> list = goodsSkuInfoService.selectGoodsSkuInfoList(goodsSkuInfo);
        return getDataTable(list);
    }
    @GetMapping("")
    public AjaxResult list()
    {
        List<GoodsSkuInfo> list = goodsSkuInfoService.selectGoodsSkuList();
        return success(list);
    }


    /**
     * 根据岗位编号获取详细信息
     */
    @GetMapping(value = "/{skuId}")
    public AjaxResult getInfo(@PathVariable Long skuId)
    {
        return success(goodsSkuInfoService.selectGoodsSkuInfoById(skuId));
    }

    /**
     * 新增岗位
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody GoodsSkuInfo goodsSkuInfo)
    {
        return toAjax(goodsSkuInfoService.insertGoodsSkuInfo(goodsSkuInfo));
    }

    /**
     * 修改岗位
     */

    @PutMapping
    public AjaxResult edit(@Validated @RequestBody GoodsSkuInfo goodsSkuInfo)
    {
        return toAjax(goodsSkuInfoService.updateGoodsSkuInfo(goodsSkuInfo));
    }

    /**
     * 删除岗位
     */

    @DeleteMapping("/{skuIds}")
    public AjaxResult remove(@PathVariable Long[] skuIds)
    {
        return toAjax(goodsSkuInfoService.deleteGoodsSkuInfoByIds(skuIds));
    }


//    /**
//     * 根据供应商
//     */
//    @GetMapping("/listBySupplier/{supplierId}")
//    public AjaxResult listBySupplier(@PathVariable Long supplierId) {
//        List<GoodsSpuInfo> list = goodsSpuInfoService.listBySupplier(supplierId);
//        return AjaxResult.success(list);
//    }

}



